Add support for background images within Elementor#1130
Add support for background images within Elementor#1130aatanasov-cloudinary merged 9 commits intodevelopfrom
Conversation
The one coming from Elementor doesn't contain all the options from the settings and therefore isn't accurate enough
aatanasov-cloudinary
left a comment
There was a problem hiding this comment.
Hi @gabriel-detassigny, I tested the PR on my side by adding a background image to a container element, and the local URL is used. The heading element works.
Back-end
Front-end
I confirm the replace_background_images_in_css hook was triggered on save (added a log to test it).
|
Thanks @aatanasov-cloudinary ! It turns out, the container elements used a slight different syntax for its keys (heading and such use Furthermore, the container applies an extra suffix internally which I couldn't retrieve directly via Elementor's internals, so I've applied it directly in that case. This fixes the issue now. I've also added some extra defensive code to check all Elementor methods interactions, as we can't be certain these methods will still exist in future versions. try {
// internal method calls.
}
catch ( \Throwable $e ) {
}however Anyway, have a look and let me know your thoughts! |
|
@gabriel-detassigny, thanks, when adding a background image to a container, I can see we have the following in the CSS:
Can you please check if we can optimize this as well (both selectors use background images delivered by Cloudinary)? Also, it will be helpful to look into the background overlay case. It uses Front-end
CMS
|
|
Thanks @aatanasov-cloudinary
So I've made changes to try to ensure we replace the existing rules (including the overlay which I've added support for). It's not an easy job though as Elementor checks for a lot of pseudo-elements, child elements, etc. And we can't guarantee this won't change in a future version. Still, it seems to work well right now, so have a look and let me know! |
aatanasov-cloudinary
left a comment
There was a problem hiding this comment.
@gabrielcld2, thanks! The background images and overlays are delivered from Cloudinary when testing containers.



This ensures that background images generated within Elementor's CSS files are handled accordingly.
Approach
QA notes